package com.dgz.friend.controller.user;

import com.dgz.common.core.constants.HttpConstants;
import com.dgz.common.core.controller.BaseController;
import com.dgz.common.core.domain.R;
import com.dgz.common.core.domain.TableDataInfo;
import com.dgz.friend.aspect.CheckUserStatus;
import com.dgz.friend.domain.exam.dto.ExamQueryDto;
import com.dgz.friend.domain.user.dto.ExamDTO;
import com.dgz.friend.service.user.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: DongGuoZhen
 * @Date: 2025/05/09/10:47
 * @Description:
 */
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {


    @Autowired
    private IUserExamService userExamService;

    /**
     * 竞赛报名
     * @param token
     * @param examDTO
     * @return
     */
    @CheckUserStatus
    @PostMapping("/enter")
    public R<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION)String token, @RequestBody ExamDTO examDTO) {
        return toR(userExamService.enter(token,examDTO.getExamId()));
    }

//    @GetMapping("/semiLogin/redis/list")
//    public TableDataInfo redisList(ExamQueryDto examQueryDto) {
//        return examService.redisList(examQueryDto);
//    }


    /**
     * 获取用户参加的竞赛列表
     * @param examQueryDto
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDto examQueryDto) {
        return userExamService.list(examQueryDto);
    }

}
